const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  pwa: {

    manifestOptions: {
      name: 'My App',
      // name:          == pwa.name
      // short_name:    == pwa.name
      // start_url: '.'
      // display: 'standalone'
      // theme_color: pwa.themeColor
    },

    workboxPluginMode: 'GenerateSW', // 'InjectManifest',
    workboxOptions: {
      cacheId: 'vue-pwa-2',
      skipWaiting: true,
      clientsClaim: true,
      mode: 'development', // 生成sw文件的模式
      runtimeCaching: [
        {
          urlPattern: /^http:\/\/juheimg.oss-cn-hangzhou.aliyuncs.com/,
          handler: 'NetworkFirst', // 网络优先
          options: {
            cacheName: 'images-cache',
            expiration: {
              maxEntries: 20, // 针对改类型的缓存的最大数量，超过替换
            },
          },
        },
        {
          urlPattern: /^http:\/\/127.0.0.1:3030\/api\/food\/getFoodList$/,
          handler: 'NetworkFirst', // 网络优先
          options: {
            cacheName: 'api-cache',
            expiration: {
              maxAgeSeconds: 10 // 过期时间，/秒
            },
          },
        }
      ]
    }
  }
})
